package com.shu.dao.impl;

import com.shu.annotaion.DataSourceName;
import com.shu.domain.constant.DataSourceConstant;
import com.shu.domain.po.User;
import com.shu.dao.UserDao;
import com.shu.mapper.UserMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;


/**
* 数据操作实现
*
* @author: shu
* @version: 1.0
* @datetime: 2017-08-14 16:54:12
*
*/
@Service("userDao")
public class UserDaoImpl implements UserDao {

    @Resource
    private UserMapper userMapper;

    @Override
    public User get(String id) {
        return userMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<User> get(User user) {
        return userMapper.select(user);
    }

    @Override
    public int delete(String id) {
        return userMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int delete(User user) {
        return userMapper.delete(user);
    }

    @Override
    @DataSourceName(DataSourceConstant.SLAVE_DATASOURCE)
    public int save(User user) {
        return userMapper.insert(user);
    }

    @Override
    public int update(User user) {
        return userMapper.update(user);
    }
}
